import { coreRemark } from '@mintlify/common';
import { formatError } from '../../errorMessages/formatError.js';
import { removeContentDirectoryPaths } from './removeContentDirectoryPaths.js';
export const preparseMdx = async (fileContent, contentDirectoryPath, filePath, suppressErrLog = false) => {
    try {
        fileContent = await preparseMdxHelper(fileContent, contentDirectoryPath);
    }
    catch (error) {
        if (!suppressErrLog) {
            console.error(formatError(error, filePath, contentDirectoryPath));
        }
        fileContent = `🚧 A parsing error occured. Please contact the owner of this website.`;
    }
    return fileContent;
};
const preparseMdxHelper = async (fileContent, contentDirectoryPath) => {
    const file = await coreRemark()
        .use(removeContentDirectoryPaths(contentDirectoryPath))
        .process(fileContent);
    return String(file);
};
